<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta charset="ISO-8859-1">
    <title>教师管理系统</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="container my-2">
    <!-- 插入公共头部 -->
    <div class="container my-2" th:insert="header :: commonHeader"></div>
    <div class="container my-2">
        <div class="container-fluid">
            <div class="row">
                <!--侧边栏-->
                <div th:replace="~{header :: sidebar }">...</div>
                <div class="col-10">
                    <div class=" ">
                        <h1>教师列表</h1>
                        <a th:href="@{/Teacher/showTeacherForm}" class="btn btn-primary btn-sm mb-3"> 新增 </a>
                        <h1  class="text-primary"></h1>
                        <nav class="navbar navbar-light bg-light">
                            <form id="query-form" action="/Teacher/query" method="get">
                                <h6 class="text-secondary">查找教师姓名</h6><input type="text" id="name-input" name="inpname" placeholder="教师名">
                                <button type="button" class="btn btn-info"onclick="queryTeacher()">搜索</button>
                            </form>
                            <hr>
                            <a th:href="@{/Teacher/}"> 回到教师列表</a>
                            <script>
                                function queryTeacher() {
                                    var Name = document.getElementById("name-input").value;
                                    var url = "/Teacher/query" + encodeURIComponent(Name);
                                    window.location.href = url;
                                }
                            </script>
                        </nav>
                        <table border="1" class="table table-striped table-responsive-md">
                            <thead>
                            <tr>
                                <th>
                                    <a th:href="@{'/Teacher/page/' + ${currentPage} + '?sortField=no&sortDir=' + ${reverseSortDir}}">
                                        教师编号</a>
                                </th>
                                <th>
                                    <a th:href="@{'/Teacher/page/' + ${currentPage} + '?sortField=name&sortDir=' + ${reverseSortDir}}">
                                        姓名</a>
                                </th>
                                <th>
                                    <a th:href="@{'/Teacher/page/' + ${currentPage} + '?sortField=age&sortDir=' + ${reverseSortDir}}">
                                        年龄</a>
                                </th>
                                <th>
                                    <a th:href="@{'/Teacher/page/' + ${currentPage} + '?sortField=sex&sortDir=' + ${reverseSortDir}}">
                                        性别</a>
                                </th>
                                <th> 功能 </th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="teacher: ${listTeacher}">
                                <td th:text="${teacher.no}"></td>
                                <td th:text="${teacher.name}"></td>
                                <td th:text="${teacher.age}"></td>
                                <td th:text="${teacher.sex}"></td>
                                <td> <a th:href="@{/Teacher/showFormForUpdate/{id}(id=${teacher.no})}" class="btn btn-primary">更新</a>
                                    <a th:href="@{/Teacher/deleteTeacher/{id}(id=${teacher.no})}" class="btn btn-danger">删除</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <div th:if = "${totalPages > 1}">
                            <div class = "row col-12">
                                <div class = "col-3">
                                    教师总数: [[${totalItems}]]    <!--/* 在thymeleaf模板引擎中获取Model中数据：var items = [[${user_name}]];  */-->
                                </div>
                                <div class = "col-4">
					<span th:each="i: ${#numbers.sequence(1, totalPages)}">
						<a th:if="${currentPage != i}" th:href="@{'/Teacher/page/' + ${i}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">[[${i}]]</a>
						<span th:unless="${currentPage != i}">[[${i}]]</span>  &nbsp; &nbsp;
					</span>
                                </div>
                                <div class = "col-2">
                                    第<a th:text="${currentPage}"></a>页
                                    /共<a th:text="${totalPages}"></a>页
                                </div>
                                <div class = "col-3">
                                    <a th:if="${currentPage > 1}" th:href="@{'/Teacher/page/' + ${1}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">首页</a>
                                    <span th:unless="${currentPage > 1}">首页</span>
                                    <a th:if="${currentPage > 1}" th:href="@{'/Teacher/page/' + ${currentPage - 1}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">上一页</a>
                                    <span th:unless="${currentPage > 1}">上一页</span>
                                    <a th:if="${currentPage < totalPages}" th:href="@{'/Teacher/page/' + ${currentPage+1}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">下一页</a>
                                    <span th:unless="${currentPage < totalPages}">下一页</span>
                                    <a th:if="${currentPage < totalPages}" th:href="@{'/Teacher/page/' + ${totalPages}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">尾页</a>
                                    <span th:unless="${currentPage < totalPages}">尾页</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<br><br><br><br><br>
    <!-- 插入公共底部 -->
    <div  th:insert="header ::bottom"></div>
</body>
</html>